#include <stdint.h>
#include "params.h"
#include "consts256.h"

#define P 10753
#define MONT 1018 // 2^16 mod p
#define MONT_PINV -6
#define PINV -10751 // p^-1 mod 2^16
#define V 12482 // floor(2^27/p + 0.5)
#define SHIFT 16
#define F 2536 // mont^2/256
#define F_PINV -1560 // PINV*F

__attribute__((aligned(32)))
const int16_t pdata10753[] = {
#define _16XP 0
  P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P,

#define _16XPINV 16
  PINV, PINV, PINV, PINV, PINV, PINV, PINV, PINV,
  PINV, PINV, PINV, PINV, PINV, PINV, PINV, PINV,

#define _16XV 32
  V, V, V, V, V, V, V, V, V, V, V, V, V, V, V, V,

#define _16XSHIFT 48
  SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT,
  SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT, SHIFT,

#define _16XMONT_PINV 64
  MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV,
  MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV, MONT_PINV,

#define _16XMONT 80
  MONT, MONT, MONT, MONT, MONT, MONT, MONT, MONT,
  MONT, MONT, MONT, MONT, MONT, MONT, MONT, MONT,

#define _16XF_PINV 96
  F_PINV, F_PINV, F_PINV, F_PINV, F_PINV, F_PINV, F_PINV, F_PINV,
  F_PINV, F_PINV, F_PINV, F_PINV, F_PINV, F_PINV, F_PINV, F_PINV,

#define _16XF 112
  F, F, F, F, F, F, F, F, F, F, F, F, F, F, F, F,

#define _ZETAS 128
   27359,  27359,  27359,  27359,  27359,  27359,  27359,  27359,
   27359,  27359,  27359,  27359,  27359,  27359,  27359,  27359,
     223,    223,    223,    223,    223,    223,    223,    223,
     223,    223,    223,    223,    223,    223,    223,    223,
   -1956,  -1956,  -1956,  -1956,  -1956,  -1956,  -1956,  -1956,
   -1956,  -1956,  -1956,  -1956,  -1956,  -1956,  -1956,  -1956,
    4188,   4188,   4188,   4188,   4188,   4188,   4188,   4188,
    4188,   4188,   4188,   4188,   4188,   4188,   4188,   4188,
   10093,  10093,  10093,  10093,  10093,  10093,  10093,  10093,
  -21094, -21094, -21094, -21094, -21094, -21094, -21094, -21094,
    2413,   2413,   2413,   2413,   2413,   2413,   2413,   2413,
   -3686,  -3686,  -3686,  -3686,  -3686,  -3686,  -3686,  -3686,
     408,    408,    408,    408,    408,    408,    408,    408,
     408,    408,    408,    408,    408,    408,    408,    408,
   -3688,  -3688,  -3688,  -3688,  -3688,  -3688,  -3688,  -3688,
   -3688,  -3688,  -3688,  -3688,  -3688,  -3688,  -3688,  -3688,
   28517,  28517,  28517,  28517,  28517,  28517,  28517,  28517,
  -20856, -20856, -20856, -20856, -20856, -20856, -20856, -20856,
     357,    357,    357,    357,    357,    357,    357,    357,
    -376,   -376,   -376,   -376,   -376,   -376,   -376,   -376,

#define _TWIST32 288
      -6,    -61,   -609,  -6095,     -6,  14237, -31235,  23836,
      -6, -19643,  -2017, -13811,     -6,  27329,  11300,  -7722,
    1018,   -573,   5023,  -3535,   1018,  -1635,   2045,  -2788,
    1018,   1349,   3615,  -5107,   1018,   5313,   5156,   -554,
    4589, -19643,    177,   1767,  24098,   1725, -31418,  -7801,
  -12378,  16236,  31558,    232,  22209,  29644, -18845,  23836,
   -3091,   1349,   2737,  -4889,  -3550,   2237,    326,   1927,
    2982,  -2196,  -2234,   4328,    193,  -5172,  -2973,  -2788,
   17675, -19863,  -2017, -20173,   4547,  -4083, -29364, -21593,
   25543,  11123,    512,  11623,   7429, -21161, -11555, -24129,
    4875,  -5015,   3615,   3891,   4035,   4621,   1356,   4519,
    2503,   2419,    512,   4967,  -4347,  -3241,   5341,  -2113,
   -5126,  14280,  11726, -13811, -20490,  24025, -24037, -13024,
  -27152, -19564,  -8801,  12415,  -6381, -26286, -31418, -23952,
   -4102,   1992,  -1586,  -5107,   3062,  -2087,   4123,   3360,
   -2576,  -1132,  -3169,   1663,   1299,   3410,    326,    624,
   -7033,  -4797,  17571, -20899,  16090,  31583,  16614, -13164,
  -29449, -19454,  17096, -16809, -12476, -26292,  -4090, -12653,
    2695,  -5309,    675,  -4003,    730,   4447,   -794,   5268,
    4855,   2050,   4808,   1111,  -2236,   4428,  -5114,  -4973,
  -12378,   7289,   7356,   8027,  15864, -31467, -24976,  16809,
   22532,   6747, -13012,   4967, -20198,  -4083,  25555, -31497,
    2982,  -2439,  -2884,   3419,  -4616,  -2283,   -400,  -1111,
       4,   2139,   1324,  -1689,  -2790,   4621,    467,   2807,
   14731,  16236,  31290, -14780, -10001,  32351,  -7795,  -9691,
   18363,   5729, -16614,  -4248,   3639,   3346,   4394,  22483,
    1931,  -2196,   -454,  -4540,   3823,   5215,    909,  -5083,
   -2629,     97,    794,   -152,   5175,    274,  -2774,  -2605,
  -16724,  29370,  31558, -12098,  27152,  12336,  19844, -22215,
    5766, -29827,   7856,  23093, -20490,  -3035, -21892,  -8935,
   -2388,  -2374,  -2234,   -834,   2576,   4144,  -2684,    825,
    4742,   3453,   -336,   3125,   3062,   1573,    636,  -2279,
      -6,  -6095,    177, -19863,     -6, -18077,  -7326,  29644,
      -6,   1767,  11726,   7289,     -6, -19661,  11141,  27329,
    1018,  -3535,   2737,  -5015,   1018,  -2205,  -2206,  -5172,
    1018,  -4889,  -1586,  -2439,   1018,   4403,   -635,   5313,
   -5126, -13811,  17571,   7289, -23781, -18918, -11555,   1725,
  -16724,    232,  -1627,  13158,  15840, -18077,  11300,  14237,
   -4102,  -5107,    675,  -2439,   4379,  -1510,   5341,   2237,
   -2388,   4328,   2981,  -4250,   -544,  -2205,   5156,  -1635,
   14731, -14780,  31558, -30144,   3925, -23952,   -780, -20070,
  -14847, -19856,  -8801,  -3699, -11683,  -7722,  -7326,  25482,
    1931,  -4540,  -2234,   2624,    341,    624,   1268,  -2662,
   -4095,   4720,  -3169,   5005,   5213,   -554,  -2206,   1930,
    2316,  22215,  -1627,  11123, -20198,  -6594, -29364,   3346,
   24269, -25652, -31887,   6747,  22209,  15328, -31235,  29644,
     268,   -825,   2981,   2419,  -2790,   4670,   1356,    274,
     205,   5068,   3441,   2139,    193,  -1056,   2045,  -5172,
  -18345,   5120,   7716, -17394,  28224,  24165, -21892,  14329,
    9508,  -4717,  -8246,  32070,  16072,   8161, -18845,  24330,
    -425,   5120,   1572,   2062,  -4544,  -3995,    636,   4601,
    3364,   2963,    970,  -1722,   3784,   2529,  -2973,    778,
  -27152, -19856,    969, -13987,  31217, -13024, -29407,   7880,
    5766,  31924, -17352, -14329, -23781,  23836,  22044,   8758,
   -2576,   4720,   -567,   2909,   1009,   3360,  -2271,  -4408,
    4742,   1204,  -5064,  -4601,   4379,  -2788,  -4580,   -458,
  -28103,  12415,  28541, -32351, -23056, -30467,   8246,  12976,
   26518, -22483,  32076,   3998,   7429, -18918, -14999, -21161,
   -5063,   1663,  -3715,  -5215,   1520,   2813,   -970,   4784,
     918,   2605,  -2740,  -1122,  -4347,  -1510,   -151,  -3241,
   24269,  20661,  17096,  -9343,  15864,   -951,  -1932, -28712,
   20198, -24641,   2395,  26286,  24098,  15517, -11555,  11952,
     205,    693,   4808,   1409,  -4616,  -2487,    116,    -40,
    2790,  -2625,  -2213,  -3410,  -3550,   -355,   5341,   3760,

#define _TWIST4 800
      -6,   -408, -27359,   1956,   1018,   3688,   -223,  -4188,
      -6,  -1956,  27359,    408,   1018,   4188,    223,  -3688,
      -6,  10093,  -1956,  28517,   1018,   2413,   4188,    357,
      -6,  20856,   -408,  21094,   1018,    376,   3688,   3686,
      -6,  -7033,  10093, -18345,   1018,   2695,   2413,   -425,
      -6, -12476,  21094,  -9508,   1018,  -2236,   3686,  -3364,
      -6, -18345,  28517, -16090,   1018,   -425,    357,   -730,
      -6,  16072,  20856, -12476,   1018,   3784,    376,  -2236
};
